﻿mui.init({
	swipeBack:false, //启用右滑关闭功能
	keyEventBind: {
		backbutton: true  //关闭back按键监听
	}
}); 
mui.plusReady(initSomething);
function initSomething(){
	//监听手机返回按键
	common.utils.confirmLoginOut();
	$(".contact_li_fortap").on("tap",function(){
		var contactInfo = plus.webview.create("contactInfo.html", "contactInfo.html", {},{"userid":"9999"});
		plus.webview.show(contactInfo, "slide-in-right", "350ms", function() {}, false);
	});
	
	initData();
}

function initData(){
	$("#loading").show();
	mui.ajax(ctx+"mobile/user/getAllUser",{
		dataType:'json',//服务器返回json格式数据
		type:'post',//HTTP请求类型
		timeout:10000,//超时时间设置为10秒；	              
		success:function(data){
	       	if(data&&data.success){
	       		initHtml(data.data);
	      	}else{
	      		alert('服务器异常链接失败!');
	      	}
	       	$("#loading").hide();
		},
		error:function(xhr,type,errorThrown){
			alert('服务器异常链接失败!');
		}
	});
}

function initHtml(data){
	var html = '';
	$.each(data,function(m,n){
			var touxiang ="";
			var yanse = "";
			var tubiao = "";
			if(data[m].sex&&data[m].sex=='0'){
				touxiang="../../img/common/woman.png";
				yanse="girl";
				tubiao="../../img/common/girl.png";
			}else{
				touxiang="../../img/common/man.png";
				yanse="boy";
				tubiao="../../img/common/boy.png";
			}
		
		html = html + '<li class="mui-table-view-cell mui-media contact_li_fortap animated fadeInRight" data-id="'+data[m].id+'" style="animation-delay:100ms" >';
		html = html + '	<a class="mui-navigate-right">';
		html = html + '		<img class="mui-media-object mui-pull-left contact-person-img" src="'+touxiang+'">';
		html = html + '			<div class="mui-media-body contact-person-font '+yanse+'">'+data[m].name;
		html = html + '			<span style="padding-left: 10px;">';
		html = html + '				<img width="15px" height="15px" src="'+tubiao+'"/></span>';
		html = html + '				<span class="tel">18678830411</span>';
		html = html + '		</div>';
		html = html + '	</a>';
		html = html + '</li>';
	});
	$("#commonContainer").html(html);
	$(".mui-table-view-cell").off("tap");
	$(".mui-table-view-cell").on("tap",function(){
		var id = $(this).attr("data-id");
		var view = plus.webview.create("contactInfo.html", "contactInfo.html", {},{"uid":id});
		//	显示新页面
		plus.webview.show(view, "slide-in-right", "350ms", function() {}, false);
	});
}
